import cn.hutool.core.io.FileUtil;
import service.DemoService;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Scanner;

public class mian {
    static String url="http://www.ghostoact.com/api/pics/getpicforR";
    //图片保存地址
    static String dir=":/LOLRandomPic";

    static DemoService service = new DemoService();
    public static void main(String[] args)throws MalformedURLException {
        System.out.println("自动下载'幽灵疾步'lol随机图片，使用前请输入盘符");

        String diskName="";
        for (;;){
            //输入盘符
            System.out.printf("请输入盘符：");
            Scanner s = new Scanner(System.in);
            diskName = s.nextLine();

            if (FileUtil.exist(diskName + ":/")){
                break;
            }else {
                System.out.println("盘符不合法");
            }
        }

        for (int a=0; a<10000;a++){
            getlist(diskName);
        }

    }

    public static void  getlist(String diskName) throws MalformedURLException {
        ArrayList<String> imgList = service.getImgList(url);

        for (String imgurl:imgList){
            System.out.print("当前地址：http:"+imgurl);
            service.saveFile("http:"+imgurl,diskName+dir);
        }
    }

}
